/**
 * 给定魔方，问是否能够还原，答案保证在8以内。
 * 首先做一个预处理，从初始态广搜8步，记录下所有的可能性
 * 然后直接回答即可
 * 考虑到时间给的很多，因此只要处理三种操作即可
 * R1、U1和F1，因为R2相当于三次R1，其余同理。
 */
#include <bits/stdc++.h>
using namespace std;
#include <bits/extc++.h>
using namespace __gnu_pbds;

using llt = long long;
using vi = vector<int>;
using pii = pair<int, int>;
using vpii = vector<pii>;
using vll = vector<llt>;

using face_t = array<string, 3>;
using cube_t = array<face_t, 6>;

template<> struct std::hash<face_t>{
    std::size_t operator () (const face_t & c) const {
        std::size_t ans = 0;
        for(const auto & s : c){
            ans = ans * 13313 + std::hash<string>()(s);
        }
        return ans;
    }
};

template<> struct std::hash<cube_t>{
    std::size_t operator () (const cube_t & c) const {
        std::size_t ans = 0;
        for(const auto & s : c){
            ans = ans * 13313 + std::hash<face_t>()(s);
        }
        return ans;
    }
};

ostream & operator << (ostream & os, const cube_t & cube){
    for(int i=0;i<3;++i){
        os << "   " << cube[0][i] << endl;
    }
    for(int i=0;i<3;++i){
        os << cube[1][i] << cube[2][i] << cube[3][i] << cube[4][i] << endl;
    }
    for(int i=0;i<3;++i){
        os << "   " << cube[5][i] << endl;
    }
    return os;
}

unordered_map<cube_t, pair<int, string>> Map;

cube_t fR1(const cube_t & c){
    static const array<int, 4> zhu = {0, 4, 5, 2};
    static const array<array<int, 6>, 4> ffu {
        array<int, 6>{2, 2, 1, 2, 0, 2},
        array<int, 6>{0, 0, 1, 0, 2, 0},
        array<int, 6>{2, 2, 1, 2, 0, 2},
        array<int, 6>{2, 2, 1, 2, 0, 2}
    };

    cube_t ans{c};
    auto & x = ans[3];
    const auto & y = c[3];
    for(int i=0;i<3;++i){
        x[i].clear();
        for(int j=2;j>=0;--j){
            x[i].push_back(y[j][i]);
        }
    }

    for(int i=0;i<4;++i){
        int curpos = zhu[i];
        int prepos = zhu[(i + 3) % 4];

        const auto & a = ffu[i];
        const auto & b = ffu[(i + 3) % 4];
        for(int j=0;j<6;j+=2){
            ans[curpos][a[j]][a[j + 1]] = c[prepos][b[j]][b[j + 1]];
        }
    }    
    return ans;
}

cube_t fR2(const cube_t & c){
    return fR1(fR1(fR1(c)));
}

cube_t fU1(const cube_t & c){
    static const array<int, 4> zhu = {0, 3, 5, 1};
    static const array<array<int, 6>, 4> ffu {
        array<int, 6>{2, 0, 2, 1, 2, 2},
        array<int, 6>{0, 0, 1, 0, 2, 0},
        array<int, 6>{0, 2, 0, 1, 0, 0},
        array<int, 6>{2, 2, 1, 2, 0, 2}
    };
    cube_t ans = c;
    auto & x = ans[2];
    const auto & y = c[2];
    for(int i=0;i<3;++i){
        x[i].clear();
        for(int j=2;j>=0;--j){
            x[i].push_back(y[j][i]);
        }
    }

    for(int i=0;i<4;++i){
        int curpos = zhu[i];
        int prepos = zhu[(i + 3) % 4];

        const auto & a = ffu[i];
        const auto & b = ffu[(i + 3) % 4];
        for(int j=0;j<6;j+=2){
            // cout << j << endl;
            ans[curpos][a[j]][a[j + 1]] = c[prepos][b[j]][b[j + 1]];
        }
    }
        
    return ans;
}

cube_t fU2(const cube_t & c){
    return fU1(fU1(fU1(c)));
}

cube_t fF1(const cube_t & c){
    static const array<int, 4> pos = {1, 2, 3, 4};
    cube_t ans = c;
    auto & x = ans[5];
    const auto & y = c[5];
    for(int i=0;i<3;++i){
        x[i].clear();
        for(int j=2;j>=0;--j){
            x[i].push_back(y[j][i]);
        }
    }

    for(int i=0;i<4;++i){
        int curpos = pos[i];
        int prepos = pos[(i + 3) % 4];
        ans[curpos][2] = c[prepos][2];
    }
    return ans;
}

cube_t fF2(const cube_t & c){
    return fF1(fF1(fF1(c)));
}

void init(){
    cube_t start;
    start[0] = {"OOO", "OOO", "OOO"};
    start[1] = {"BBB", "BBB", "BBB"};
    start[2] = {"YYY", "YYY", "YYY"};
    start[3] = {"GGG", "GGG", "GGG"};
    start[4] = {"WWW", "WWW", "WWW"};
    start[5] = {"RRR", "RRR", "RRR"};

    Map.insert({start, {0, ""}});
    queue<cube_t> q;
    q.push(start);

    int sz = 0;
    int k = 0;
    while(sz = q.size()){
        ++k;
        if(k > 8) break;
        while(sz--){
            auto h = q.front(); q.pop();

            auto it = Map.find(h);
            assert(it != Map.end());
            string buzhou = it->second.second;

            auto tmp = fR1(h);
            auto jt = Map.find(tmp);
            if(jt == Map.end()){
                jt = Map.insert(jt, {tmp, {k, buzhou + "R1"}});
                q.push(tmp);
            }

            tmp = fR2(h);
            jt = Map.find(tmp);
            if(jt == Map.end()){
                jt = Map.insert(jt, {tmp, {k, buzhou + "R2"}});
                q.push(tmp);
            }

            tmp = fU1(h);
            jt = Map.find(tmp);
            if(jt == Map.end()){
                jt = Map.insert(jt, {tmp, {k, buzhou + "U1"}});
                q.push(tmp);
            }

            tmp = fU2(h);
            jt = Map.find(tmp);
            if(jt == Map.end()){
                jt = Map.insert(jt, {tmp, {k, buzhou + "U2"}});
                q.push(tmp);
            }

            tmp = fF1(h);
            jt = Map.find(tmp);
            if(jt == Map.end()){
                jt = Map.insert(jt, {tmp, {k, buzhou + "F1"}});
                q.push(tmp);
            }

            tmp = fF2(h);
            jt = Map.find(tmp);
            if(jt == Map.end()){
                jt = Map.insert(jt, {tmp, {k, buzhou + "F2"}});
                q.push(tmp);
            }
        }
    }
    return;
}

void work(){ 
    cube_t c;
    for(int i=0;i<3;++i){
        for(int j=0;j<3;++j){
            char ch; cin >> ch;
            c[0][i] += ch;
        }
    }
    for(int i=0;i<3;++i){
        for(int j=1;j<=4;++j){
            char c1, c2, c3;
            cin >> c1 >> c2 >> c3;
            c[j][i] += c1;
            c[j][i] += c2;
            c[j][i] += c3;
        }
    }
    for(int i=0;i<3;++i){
        for(int j=0;j<3;++j){
            char ch; cin >> ch;
            c[5][i] += ch;
        }
    }
#ifndef ONLINE_JUDGE
    cout << c << endl;
#endif
    auto it = Map.find(c);
    assert(it != Map.end());
    
    int k = it->second.first;
    const auto & s = it->second.second;
    assert(s.length() == k + k);
    cout << k << endl;
    for(int i=k+k-2;i>=0;i-=2){
        cout << s[i] << (char)(s[i + 1] ^ '1' ^ '2') << endl;
    }
	return;
}

int main(){
#ifndef ONLINE_JUDGE
    freopen("z.txt", "r", stdin);
#endif
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);	
    int nofkase = 1;
	// cin >> nofkase;
    init();
	while(nofkase--) work();
	return 0;
}